import { Module } from '@nestjs/common';
import { TodoListService } from './todo-list.service';
import { TodoListController } from './todo-list.controller';
import { MongooseModule } from '@nestjs/mongoose';
import { RepositoryImpl } from './data/todo-list.repository.impl';
import { Repository } from './data/todo-list.repository';
import { ApiService } from './todo-list.apiservice';
import { Todo, TodoSchema } from '../schema/todo.schema';
import { GetAllTodosUseCase } from './domain/usecase.getall';
import { GetAllTodosUseCaseImpl } from './domain/usercase.getall.impl';

const todoSchemaModule = MongooseModule.forFeature([
  { name: Todo.name, schema: TodoSchema, collection: 'Todo' },
]);

const localProvider = [
  TodoListService,
  {
    provide: Repository,
    useClass: RepositoryImpl,
  },
  {
    provide: GetAllTodosUseCase,
    useClass: GetAllTodosUseCaseImpl,
  },
  ApiService,
];

@Module({
  imports: [todoSchemaModule],
  controllers: [TodoListController],
  providers: localProvider,
})
export class TodoListModule {}
